package com.mgq.java8.lambda;

import java.util.function.BinaryOperator;
import java.util.function.UnaryOperator;

/**
 * <b>功能：</b>一元操作符测试<br>
 * <b>Copyright TCSL</b>
 * <li>版本&nbsp;&nbsp;&nbsp;&nbsp;修改日期&nbsp;&nbsp;&nbsp;&nbsp;部　　门&nbsp;&nbsp;&nbsp;&nbsp;作　者&nbsp;&nbsp;&nbsp;&nbsp;变更内容</li><hr>
 * <li>v1.0&nbsp;&nbsp;&nbsp;&nbsp;20220412&nbsp;&nbsp;营业后台&nbsp;&nbsp;&nbsp;&nbsp;马广奇&nbsp;&nbsp;&nbsp;&nbsp;创建类</li>
 * <br><br>
 *
 * @author 马广奇
 * @version 2022-04-12 21:04
 */
public class UnaryOperatorTest {
    public static void test() {
        //一元操作符 UnaryOperator接收一个参数，返回和参数同样类型的结果
        UnaryOperator<String> unaryOperator = String::toLowerCase;
        UnaryOperator<String> unaryOperator2 = s -> s.substring(2);

        BinaryOperator<String> binaryOperator = (s1, s2) -> s1.substring(2).concat(s2.substring(2));

        System.out.println(unaryOperator.apply("hello world"));
        System.out.println(unaryOperator2.apply("hello world"));

        System.out.println(binaryOperator.apply("hello","world"));
    }

    public static void main(String[] args) {
        test();
    }
}
